Optimized implementation for structured matrices#139
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #139 +/- ##
==========================================
Coverage 100.00% 100.00%
==========================================
Files 17 20 +3
Lines 1939 2070 +131
==========================================
+ Hits 1939 2070 +131 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Bump on this PR, what else do we need to finalize this PR? I can add the decompression for GPU-based structured matrices. |
|
If you have some cycles to spare to merge |
|
Sure thing, I will first start to merge the main branch into this branch. |
|
Thanks! Ping me if you have any questions |
Fixes #64 and fixes #65 by optimizing structured coloring & decompression for these matrix types:
DiagonalBidiagonalTridiagonalBandedMatrixBlockBandedMatrixBandedBlockBandedMatrixFor
BandedMatrixandBlockBandedMatrix, the standard decompression based onSparseMatrixCSCwill work fine because their storage is column-major (ref1, ref2). We only need a specific overload forBandedBlockBandedMatrix, which is aBlockMatrixofBandedMatrix-like blocks (so we need to decompress block by block).General philosophy
Separate coloring from decompression:
StructuredColoringAlgorithmthat uses optimal coloring formulas (note that for block-banded the coloring given here is not actually optimal if the blocks themselves are sparse).ColumnColoringResult/RowColoringResult), which means that even greedy colorings on structured matrices benefit from optimized decompression.Remaning issues
For decompression of BlockBandedMatrices, I still need to figure out JuliaArrays/BlockArrays.jl#418. But it already works because the fallback algorithm relies on the nonzeros of the sparse encoding, so it does not try to access illegal indices outside of the bands.
Implementation details
This is a clean rewrite of some code that was already present in ArrayInterface.jl and FiniteDiff.jl:
https://github.com/JuliaArrays/ArrayInterface.jl/blob/2e2b81bfb53e9e9fc41f26b927fb980afcbfa9f5/src/ArrayInterface.jl#L372-L384
https://github.com/JuliaArrays/ArrayInterface.jl/blob/2e2b81bfb53e9e9fc41f26b927fb980afcbfa9f5/ext/ArrayInterfaceBandedMatricesExt.jl#L68-L72
https://github.com/JuliaArrays/ArrayInterface.jl/blob/2e2b81bfb53e9e9fc41f26b927fb980afcbfa9f5/ext/ArrayInterfaceBlockBandedMatricesExt.jl#L207-L244
https://github.com/JuliaDiff/FiniteDiff.jl/blob/b574440c5d54708aa23a90c48f4a000dd1c6d915/ext/FiniteDiffBandedMatricesExt.jl#L13-L27
I still need to implement optimal decompression for block-banded matrices.
https://github.com/JuliaDiff/FiniteDiff.jl/blob/b574440c5d54708aa23a90c48f4a000dd1c6d915/ext/FiniteDiffBlockBandedMatricesExt.jl#L16-L68